<template>
	<view class="container">
		<view class="card">
			<u-cell-group :border="false">
				<u-cell title="主体名称" :value="member.entityName" :arrow="false"></u-cell>
				<u-cell title="法人姓名" :value="member.legalPerson" :arrow="false"></u-cell>
				<u-cell title="联系电话" :value="member.phone" :arrow="false"></u-cell>
				<u-cell title="所属行业" :value="member.industry" :arrow="false"></u-cell>
				<u-cell title="生产类型" :value="member.productionType" :arrow="false"></u-cell>
				<u-cell title="主体地址" :value="member.address" :arrow="false"></u-cell>
				<u-cell title="主体类型" :value="member.entityType" :arrow="false"></u-cell>
				<u-cell title="身份证号码" :value="member.idCard" :arrow="false"></u-cell>
				<u-cell title="统一社会信用代码" :value="member.creditCode" :arrow="false"></u-cell>
				<u-cell title="注册资金" :value="member.registeredCapital" :arrow="false"></u-cell>
				<u-cell title="成立时间" :value="member.establishmentDate" :arrow="false"></u-cell>
			</u-cell-group>
		</view>

		<view class="card">
			<view class="card-title">营业执照: {{member.isBusinessLicense ? '有' : '无' }}</view>
			<!-- TODO: 图片应从接口获取 -->
			<image v-if="member.businessLicenseUrl" :src="member.businessLicenseUrl" mode="widthFix" class="image-preview"></image>
			<view v-else class="no-image">暂无</view>
		</view>

		<view class="card">
			<view class="card-title">认证资质: {{member.isQualification ? '有' : '无' }}</view>
			<!-- TODO: 图片应从接口获取 -->
			<image v-if="member.qualificationUrl" :src="member.qualificationUrl" mode="widthFix" class="image-preview"></image>
			<view v-else class="no-image">暂无</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			memberId: null,
			member: {}
		};
	},
	onLoad(options) {
		this.memberId = options.id;
		this.fetchMemberDetail();
	},
	methods: {
		fetchMemberDetail() {
			// TODO: 调用接口，根据this.memberId获取会员详情
			const mockData = {
				id: 1,
				entityName: '六六六生产主体',
				legalPerson: '六六六',
				phone: '18408248888',
				industry: '农业',
				productionType: '种植+养殖',
				address: '四川省成都市郫都区郫筒街道众创空间',
				entityType: '个体工商户',
				idCard: '暂无数据',
				creditCode: '11111111111111',
				registeredCapital: '1000',
				establishmentDate: '2023年08月01日',
				isBusinessLicense: true,
				businessLicenseUrl: '', 
				isQualification: true,
				qualificationUrl: ''
			};
			this.member = mockData;
		}
	}
};
</script>

<style lang="scss" scoped>
.container {
	padding: 20rpx;
	background-color: #f5f5f5;
	min-height: 100vh;
}
.card {
	background-color: #fff;
	border-radius: 16rpx;
	margin-bottom: 20rpx;
	padding: 0 20rpx;
}
.card-title {
	font-size: 30rpx;
	font-weight: bold;
	padding: 20rpx 0;
	border-bottom: 1rpx solid #eee;
}
.image-preview {
	width: 100%;
	padding: 20rpx 0;
}
.no-image {
	color: #909399;
	text-align: center;
	padding: 40rpx 0;
}
</style>